package com.example.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.example.mapper.DoctorMapper;
import com.example.entity.Doctor;
import com.example.service.IDoctorService;

/**
 * 医生Service业务层处理
 * 
 * @author wyx
 * @date 2025-03-12
 */
@Service
public class DoctorServiceImpl extends ServiceImpl<DoctorMapper, Doctor> implements IDoctorService
{

    @Override
    public List<Doctor> listDoctor(String name, String departmentId, Integer status, Integer pageNum, Integer pageSize) {
        QueryWrapper<Doctor> queryWrapper = new QueryWrapper<>();
        if (name != null) queryWrapper.like("name", name);
        if (departmentId != null) queryWrapper.eq("department_id", departmentId);
        if (status != null) queryWrapper.eq("status", status);

        Page<Doctor> page = new Page<>(pageNum, pageSize);
        if (pageNum != null && pageSize != null) {
            return this.page(page, queryWrapper).getRecords();
        } else {
            return this.list(queryWrapper);
        }
    }


}
